package org.zqy.util;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 * 自定义日志类
 * 
 * @author zqy
 * 
 */
public class MyLog {
	// Logger实例
	public Logger logger = null;

	// 将Log类封装为单例模式
	private static MyLog log;

	// 构造函数，用于初始化Logger配置需要的属性
	private MyLog() {
		// 获得日志类logger的实例
		logger = Logger.getLogger(this.getClass());
		// logger所需的配置文件路径
		String path = this.getClass().getClassLoader().getResource("/").getPath();
		PropertyConfigurator.configure(path+"/conf/log4j.properties");
	}

	public static MyLog getLogger() {
		if (log == null) {
			log = new MyLog();
		}
		return log;
	}

}
